program pic

   implicit none
   integer c,a
   integer b(5)
   real fmedian
   external fmedian
   c=5
   b=(/9,2,7,1,6/)
   print *, fmedian(a,b,c)

end program pic


real function fmedian(xmed,x,n)
   double precision sum
   integer i,n,xmed
   integer,dimension(n):: x
   sum=0.d0
   do i=1,n
      sum=sum+(x(i)-xmed)/abs(x(i)-xmed)
   end do
   fmedian= sum
   return
end function fmedian
